package sqlist;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2023-10-28
 * Time：15:07
 */
class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> one = new ArrayList<>();
        one.add(1);
        ret.add(one);
        for(int i = 1; i < numRows; i++) {
            List<Integer> curRow = new ArrayList<>(i + 1);
            List<Integer> preRow = ret.get(i-1);
            curRow.add(1);
            for(int j = 1; j < i; j++) {
                int value = preRow.get(j-1) + preRow.get(j);
                curRow.add(value);
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
}
public class YhTriangle {
    public static void main(String[] args) {
        Solution s = new Solution();
        List<List<Integer>> ret = s.generate(5);
        System.out.println(ret);
    }
}
